//
// Created by XiongYingqi on 14-5-22.
// Copyright (c) 2014 XiongYingqi. All rights reserved.
//

#import "KRCommonTabBar.h"
#import "RDVTabBarController.h"
#import "RDVTabBarItem.h"
#import "KRAppDelegate.h"


@implementation KRCommonTabBar {


}


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
//    if (self) {
//        self.title = @"First";
//    }
    return self;
}

#pragma mark - View lifecycle

- (void)viewDidLoad {
    [super viewDidLoad];

//    [[self rdv_tabBarItem] setBadgeValue:@"3"];
    NSLog(@"[KRAppDelegate appDelegate].tabBarController.tabBar ============ %@", [KRAppDelegate appDelegate].tabBarController.tabBar);
    if ([KRAppDelegate appDelegate].tabBarController.tabBar) {

        CGFloat height = CGRectGetHeight([KRAppDelegate appDelegate].tabBarController.tabBar.frame);
        CGRect frame = self.view.frame;
        frame.size.height -= height;
        frame.origin.y -= height;
        self.view.frame = frame;
        NSLog(@"height ============ %f", height);
    }

    if (self.rdv_tabBarController.tabBar.translucent) {
        CGFloat height = CGRectGetHeight(self.rdv_tabBarController.tabBar.frame);
        CGRect frame = self.view.frame;
        frame.size.height -= height;
        self.view.frame = frame;

        NSLog(@"rdv_tabBarController.tabBar.height ======== %f", height);

    }
}

- (void)viewWillAppear:(BOOL)animated {
    if ([KRAppDelegate appDelegate].tabBarController.tabBar) {

        CGFloat height = CGRectGetHeight([KRAppDelegate appDelegate].tabBarController.tabBar.frame);
        CGRect frame = self.view.frame;
        frame.size.height -= height;
        self.view.frame = frame;
        NSLog(@"height ============ %f", height);
    }
}

//- (NSUInteger)supportedInterfaceOrientations {
//    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
//        return UIInterfaceOrientationMaskAll;
//    } else {
//        return UIInterfaceOrientationMaskPortrait;
//    }
//}
//
//- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
//    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
//        return YES;
//    }
//    return toInterfaceOrientation == UIInterfaceOrientationPortrait;
//}

//#pragma mark - Methods
//
//- (void)configureCell:(UITableViewCell *)cell forIndexPath:(NSIndexPath *)indexPath {
//    [[cell textLabel] setText:[NSString stringWithFormat:@"%@ Controller Cell %d", self.title, indexPath.row]];
//}

//#pragma mark - Table view

//- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//    static NSString *CellIdentifier = @"Cell";
//    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
//    if (!cell) {
//        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
//    }
//
//    [self configureCell:cell forIndexPath:indexPath];
//
//    return cell;
//}

//- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
//    [tableView deselectRowAtIndexPath:indexPath animated:YES];
//
//    [[self rdv_tabBarItem] setBadgeValue:[NSString stringWithFormat:@"%d", indexPath.row+1]];
//
//    [[self rdv_tabBarController] setTabBarHidden:!self.rdv_tabBarController.tabBarHidden animated:YES];
//}

@end